package edu.gym4all.service.domain;

import java.util.ArrayList;
import java.util.List;

import android.nfc.Tag;
import android.os.Parcel;
import android.os.Parcelable;
import edu.gym4all.service.enums.TrainingTag;

public class Training implements Parcelable {

	private List<Hypertrophy> listHyper = new ArrayList<Hypertrophy>();

	private List<Cardio> listCardio = new ArrayList<Cardio>();

	private TrainingTag tag;

	private long id;

	public Training(TrainingTag tag) {
		this.tag = tag;
	}

	public Training(Parcel dest) {
		this.readFromParcel(dest);
	}

	public long getID() {
		return this.id;
	}

	public void setID(long id) {
		this.id = id;
	}

	public List<Hypertrophy> getListHyper() {
		return this.listHyper;
	}

	public void setListHyper(List<Hypertrophy> listHyper) {
		this.listHyper = listHyper;
	}

	public void addHyperExercise(Hypertrophy exercise) {
		this.listHyper.add(exercise);
	}

	public void removeHyperExercise(Hypertrophy exercise) {
		this.listHyper.remove(exercise);
	}

	public List<Cardio> getListCardio() {
		return this.listCardio;
	}

	public void setListCardio(List<Cardio> listCardio) {
		this.listCardio = listCardio;
	}

	public void addCardioExercise(Cardio exercise) {
		this.listCardio.add(exercise);
	}

	public void removeCardioExercise(Cardio exercise) {
		this.listCardio.remove(exercise);
	}

	public TrainingTag getTag() {
		return this.tag;
	}

	@Override
	public String toString() {
		return "Training " + this.getTag();
	}

	@Override
	public int describeContents() {
		return 0;
	}

	public static final Parcelable.Creator<Training> CREATOR = new Parcelable.Creator<Training>() {

		@Override
		public Training createFromParcel(Parcel source) {
			return new Training(source);
		}

		@Override
		public Training[] newArray(int size) {
			return new Training[size];
		}
	};

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeList(this.listHyper);
		dest.writeList(this.listCardio);
		dest.writeParcelable(this.tag, flags);
	}

	private void readFromParcel(Parcel in) {
		in.readList(this.listHyper, Hypertrophy.class.getClassLoader());
		in.readList(this.listCardio, Cardio.class.getClassLoader());
		this.tag = in.readParcelable(Tag.class.getClassLoader());
	}
}